﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Lilium.Reflection
{
	public static class TypeExtensions
	{
		public static FieldInfo GetField(this Type type, string fieldName, BindingFlags bindingFlags, bool requred)
		{
			if (type == null) throw new ArgumentNullException("type");

			var field = type.GetField(fieldName, bindingFlags);
			if ((field == null) && requred)
				throw new NotImplementedException(string.Format("Required field {0} not found on type {1}", fieldName, type));

			return field;
		}
	}
}
